<script>
	import Vue from 'vue'
	export default {
		data(){
			return{
				isBeingRecorded: false,
				      isScreenshotDetected: false
			}
		},
		onLoad:function(){
			this.opentshow();
			this.addFlags();
			 // 监听截屏事件
			    this.screenshotListener = uni.$on('screenshotDetected', () => {
			      this.isScreenshotDetected = true;
			      // 3秒后恢复显示（可选）
			      setTimeout(() => {
			        this.isScreenshotDetected = false;
			      }, 3000);
			    });
			    
			    // 监听录屏开始事件
			    this.recordingStartListener = uni.$on('recordingStarted', () => {
			      this.isBeingRecorded = true;
			    });
			    
			    // 监听录屏结束事件
			    this.recordingStopListener = uni.$on('recordingStopped', () => {
			      this.isBeingRecorded = false;
			    });

		},
		onLaunch: function() {
			
			const extConfig = uni.getExtConfigSync ? uni.getExtConfigSync() : {};
			if(extConfig.appid){
				this.$config.appId = extConfig.appid;
			}
		},
		onShow: function() {
			this.opentshow();
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		onUnload() {
			this.clearFlags()
		},
		methods:{
			opentshow(){
				let data = {};
				data.token = uni.getStorageSync("userinfo").token;
				uni.request({
					url: this.configs.webUrl + '/api/hyk/hyk_info',
					data: data,
					success: data => {
						console.log('是否为会员',data.data.data)
					uni.setStorageSync('Info', data.data.data); // 自动转为 
					},
					fail: (data, code) => {}
				})
			},
			// 禁止截屏
			addFlags() {
				// #ifdef APP-PLUS
				console.log('plus.os',plus.os);
				let osname = plus.os.name
				if (osname == "Android") {
					var activity = plus.android.runtimeMainActivity()
					console.log(activity);
					console.log('开启防截屏');
					plus.android.invoke(plus.android.invoke(activity, "getWindow"), "addFlags", 0x00002000)
				}
				// #endif
			},
			//  允许截屏  
			clearFlags() {
				// #ifdef APP-PLUS
				let osname = plus.os.name
				if (osname == "Android") {
					var activity = plus.android.runtimeMainActivity()
					console.log('关闭防截屏');
					plus.android.invoke(plus.android.invoke(activity, "getWindow"), "clearFlags", 0x00002000)
				}
				// #endif
			},
		}
	}
</script>

<style lang="scss">
	/* #ifndef APP-PLUS-NVUE */
	@import url("./static/css/common.css");
	/* #endif */
	@import "@/uni_modules/uview-ui/index.scss";
	page{
		background: #000000;
	}
	@font-face {
	  font-family: 'Roboto';
	  font-style: italic;
	  font-weight: bold;
	  src: url(https://fonts.gstatic.com/s/roboto/v48/KFO7CnqEu92Fr1ME7kSn66aGLdTylUAMa3KUBHMdazTgWw.woff2) format('woff2');
	}
	
	.fonst1 {
	  font-family: 'Roboto', sans-serif;
	  font-size: 16px;
	  // color: white;
	  transform: skewX(-10deg); /* 向左倾斜 */
	  font-weight: bold; /* 加粗字体 */
	  text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5); /* 增加立体感效果 */
	}
	.fonst2 {
	  font-family: 'Roboto', sans-serif;
	  font-size: 14px;
	  // color: white;
	  transform: skewX(-10deg); /* 向左倾斜 */
	  font-weight: bold; /* 加粗字体 */
	  text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5); /* 增加立体感效果 */
	}
	.uni-tabbar-border{
		background-color: transparent !important;
		height: 0 !important;
		border: none !important;
	}
	uni-modal .uni-modal {
	    position: fixed;
	    z-index: 999;
	    width: 80%;
	    max-width: 300px;
	    top: 50%;
	    left: 50%;
	    -webkit-transform: translate(-50%, -50%);
	    transform: translate(-50%, -50%);
	    background-color: #403b3b;
	    text-align: center;
	    border-radius: 3px;
	    overflow: hidden;
	    color: #fff;
	}
	// ::v-deep uni-modal .uni-modal__btn {
	//     display: block;
	//     -webkit-box-flex: 1;
	//     -webkit-flex: 1;
	//     flex: 1;
	//     color: #fff !important;
	//     text-decoration: none;
	//     -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
	//     position: relative;
	//     cursor: pointer;
	// }
	uni-modal .uni-modal__title {
	    word-wrap: break-word;
	    word-break: break-all;
	    white-space: pre-wrap;
	    color: cornflowerblue;
	}
	
</style>
